package cn.tedu.hospital.physicans.service.serviceImp;

import cn.tedu.hospital.base.exception.ServiceException;
import cn.tedu.hospital.base.response.JsonResult;
import cn.tedu.hospital.base.response.StatusCode;
import cn.tedu.hospital.physicans.mapper.PhysicansMapper;
import cn.tedu.hospital.physicans.pojo.dto.LoginParam;
import cn.tedu.hospital.physicans.pojo.vo.LoginVO;
import cn.tedu.hospital.physicans.service.PhysicansService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class PhysicansServiceImp implements PhysicansService {
    @Autowired
    private PhysicansMapper physicansMapper;
    @Override
    public LoginVO login(LoginParam loginParam) {
        LoginVO loginVO =physicansMapper.login(loginParam);
        log.debug("", loginVO);
        if (loginVO == null){
            throw new ServiceException(StatusCode.USERNAME_ERROR);
        }
        if (!loginVO.getPassword().equals(loginParam.getPassword())){
            throw new ServiceException(StatusCode.PASSWORD_ERROR);
        }
        return loginVO;
    }
}
